﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Wedo.Recognition.Domain.Models;
using System.ComponentModel; 
using Wedo.Mvc.Utility;
using System.ComponentModel.DataAnnotations;

namespace Wedo.Domain.Models
{
    /// <summary>
    /// 系统参数
    /// </summary>
    public class SysParam 
    {
        /// <summary>
        /// 参数层级,3位一层
        /// </summary>
        [DisplayName("编号")]
        [Required(ErrorMessage = "{0} 不能为空！")]
        public string Id { get; set; }

       /// <summary>
       /// 目录级别
       /// </summary>
        public int Level { get { return (Id ?? "").Length / 3; } } 

        /// <summary>
        /// 父层
        /// </summary>
        /// <returns></returns>
        public string ParentID()
        {
            return Id.Substring(0, Id.Length - 3);
        }

        /// <summary>
        /// 参数名
        /// </summary>
        [DisplayName("参数名")]
        [Required(ErrorMessage = "{0} 不能为空！")]
        public string ParamText { get; set; }

        /// <summary>
        /// 参数值
        /// </summary>
        [DisplayName("参数值")]
        [Required(ErrorMessage = "{0} 不能为空！")]
        public string ParamValue { get; set; }
    }
}
